import React, {useReducer, useState} from 'react';
import {Provider} from "./context";
import store from "./store"
import Child from "./components/Child";
function App(props) {
    const [state,dispatch] = useReducer(store,{
        userName:"zhangsan",
        age:12
    });
    return (
        <Provider value={{state,dispatch}}>
            <button onClick={()=>{
                dispatch({type:"UP_USERNAME",payload:"lisi"});
            }}>{state.userName}</button>
            <button onClick={()=>dispatch({type:"UP_AGE",payload:200})}>{state.age}</button>
            <hr/>
            <Child/>
        </Provider>
    );
}

export default App;